//
//  YFUIHelper.h
//  SquashSpark
//
//  Created by Coollang on 2017/10/30.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#ifndef YFUIHelper_h
#define YFUIHelper_h

#import "UIFont+ItalicFont.h"

#define kOpenSansFont(TYPE,SIZE) [UIFont openSansFont:TYPE size:SIZE]

#define kOpenSansExtraBold(SIZE) [UIFont fontWithName:@"OpenSans-ExtraBold" size:SIZE]

#define kYFScreenWidth  ApplicationBounds().size.width
#define kYFScreenHeight ApplicationBounds().size.height

/// 纯代码适配等比例拉伸(以iPhone6/6s计算)
#define kSCREEN_WIDTH_RATIO (kYFScreenWidth/375.0)
#define kSCREEN_HEIGHT_RATIO (kYFScreenHeight<500?1:kYFScreenHeight/667.0) /// 5/5s以下不做等比例缩放
#define kAutoWid(w) (w*kSCREEN_WIDTH_RATIO)
#define kAutoHei(h) (h*kSCREEN_HEIGHT_RATIO)


// 做iPhoneX适配
#define  adjustsScrollViewInsets_NO(scrollView,vc)\
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
if ([UIScrollView instancesRespondToSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:")]) {\
[scrollView   performSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:") withObject:@(2)];\
} else {\
vc.automaticallyAdjustsScrollViewInsets = NO;\
}\
_Pragma("clang diagnostic pop") \
} while (0)

/**
 *  Converts degree to radian
 */
#define DEGREES_TO_RADIANS(x) ((M_PI * (x)) / 180.0)

#define IS_IPHONE_5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define IS_IPHONE_6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? (CGSizeEqualToSize(CGSizeMake(750,1334), [[UIScreen mainScreen] currentMode].size) || CGSizeEqualToSize(CGSizeMake(640,1136), [[UIScreen mainScreen] currentMode].size)) : NO)
#define IS_IPHONE_6PLUS ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? (CGSizeEqualToSize(CGSizeMake(1125,2001), [[UIScreen mainScreen] currentMode].size) || CGSizeEqualToSize(CGSizeMake(1242,2208), [[UIScreen mainScreen] currentMode].size)) : NO)

#define kDevice_Is_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)//iPhone X手机
//iPhone X 适配
#define         kIphoneXNaviHeight  88
#define         kIphoneNaviHeight   64

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPAD_PRO_1366 (IS_IPAD && MAX(SCREEN_WIDTH,SCREEN_HEIGHT) == 1366.0)
#define IS_IPAD_PRO_1024 (IS_IPAD && MAX(SCREEN_WIDTH,SCREEN_HEIGHT) == 1024.0)

// 公用图片
#define         kUserHeadPlaceholdImage             [UIImage imageNamed:@"defalut_headIocn"]
#define         kSquashLogoPlaceholdImage             [UIImage imageNamed:@"squash_logo"]

// 朋友圈占位图片
#define         kPlaceholdImage             [UIImage imageNamed:@"placeholder"]
#define         kHeaderPlaceholdImage       [UIImage imageNamed:@"defalut_headIocn"]

#endif /* YFUIHelper_h */
